package com.aizhixin.test.conf;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;

@Configuration
@EnableSwagger2
@SuppressWarnings("unchecked")
public class SwaggerConfig {
	@Value("${sys.version}")
	private String systemPublish;
	
	
	@Bean
    public Docket testApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("排行榜API")
                .pathMapping("/")
                .select()
                .paths(or(regex("/v1/open/paihangbang/.*")))//过滤的接口
                .build()
                .apiInfo(new ApiInfoBuilder()
                        .title("排行榜API")
                        .version(systemPublish)
                        .build());
    }
	@Bean
    public Docket testApi2() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("答题（题来答）的API")
                .pathMapping("/")
                .select()
                .paths(or(regex("/v1/open/anserQuestion/.*")))//过滤的接口
                .build()
                .apiInfo(new ApiInfoBuilder()
                        .title("答题的API")
                        .version(systemPublish)
                        .build());
    }
	@Bean
	public Docket testApi3() {
		return new Docket(DocumentationType.SWAGGER_2)
					.groupName("查看某个用户每日答题情况每日答题的API")
					.pathMapping("/")
					.select()
					.paths(or(regex("/v1/open/answerEverdayRecord/.*")))
					.build()
	                .apiInfo(new ApiInfoBuilder()
	                        .title("查看某个用户每日答题情况每日答题的API")
	                        .version(systemPublish)
	                        .build());
	}
	@Bean
	public Docket testApi4() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("输入用户id后查看答题汇总信息表API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/allAnserRecord/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("输入用户id后查看答题汇总信息表API")
						.version(systemPublish)
						.build());
	}
	@Bean
	public Docket testAPi5() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("答题记录API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/anserRecord/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("答题记录API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi6() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("用户答题后提交答题判断并且修改三表API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/anserQuestionJudge/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("用户答题后提交答题判断并且修改三表API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi7() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("查看个人排行表API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/gerenPaihangbang/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("查看个人排行表API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi8() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("注册与登陆所需的API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/userImformation/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("注册与登陆所需的API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi9() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("错题集API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/findErrolAll/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("错题集API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi10() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("计算来了app多少天的API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/timedifferecen/.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("计算来了app多少天的API")
						.version(systemPublish)
						.build());
		
	}
	@Bean
	public Docket testAPi11() {
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("对试题的增删改API")
				.pathMapping("/")
				.select()
				.paths(or(regex("/v1/open/masterAddOrChangeQuestion.*")))
				.build()
				.apiInfo(new ApiInfoBuilder()
						.title("对试题的增删改API")
						.version(systemPublish)
						.build());
		
	}
  
}
